unit SellMain;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Objects,
  FMX.StdCtrls, FMX.Layouts, System.Actions, FMX.ActnList, FMX.Gestures,
  FMX.Edit, FMX.TabControl, Data.Bind.EngExt, Fmx.Bind.DBEngExt, System.Rtti,
  System.Bindings.Outputs, Fmx.Bind.Editors, Data.Bind.Components;

type
  TSellPage = class(TForm)
    lHeader: TLayout;
    lFooter: TLayout;
    btBack: TButton;
    btSetting: TImage;
    txtOrderStatus: TLayout;
    txtOwner: TLayout;
    Layout3: TLayout;
    Layout4: TLayout;
    lContainer: TLayout;
    TabContainer: TTabControl;
    t1: TTabItem;
    TabItem2: TTabItem;
    TabItem3: TTabItem;
    TabItem4: TTabItem;
    TabItem5: TTabItem;
    t1Top: TLayout;
    Label1: TLabel;
    txtCode: TEdit;
    lNav: TLayout;
    GestureManager1: TGestureManager;
    TabActionList: TActionList;
    ChangeTabActionPrev: TChangeTabAction;
    ChangeTabActionNext: TChangeTabAction;
    t1l: TLayout;
    l1: TLayout;
    l2: TLayout;

    procedure ChangeTabActionPrevUpdate(Sender: TObject);
    procedure ChangeTabActionNextUpdate(Sender: TObject);
    procedure t1lResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    FLayoutLandscape: TLayout;
    FLayoutPortrait: TLayout;
  end;

var
  SellPage: TSellPage;
  CurTab: Integer;
  FLayoutLandscape: TLayout;
  FLayoutPortrait: TLayout;
  W,H : INTEGER;

implementation

{$R *.fmx}

procedure TSellPage.ChangeTabActionNextUpdate(Sender: TObject);
begin
   if TabContainer.TabIndex < TabContainer.TabCount -1 then
    ChangeTabActionNext.Tab := TabContainer.Tabs[TabContainer.TabIndex + 1]
  else
    {ChangeTabActionNext.Tab := nil;}
      if TabContainer.TabIndex >= TabContainer.TabCount -1 then
      ChangeTabActionNext.Tab := TabContainer.Tabs[0]
      else ChangeTabActionNext.Tab := nil;

  if TabContainer.TabIndex > 0 then
    ChangeTabActionPrev.Tab := TabContainer.Tabs[TabContainer.TabIndex - 1]
  else
    ChangeTabActionPrev.Tab := nil;

  CurTab := TabContainer.TabIndex;

end;

procedure TSellPage.ChangeTabActionPrevUpdate(Sender: TObject);
begin
  if TabContainer.TabIndex < TabContainer.TabCount-1 then
     ChangeTabActionNext.Tab:= TabContainer.Tabs[TabContainer.TabIndex + 1]
  else
    ChangeTabActionNext.Tab := nil;

  if TabContainer.TabIndex > 0 then
    ChangeTabActionPrev.Tab := TabContainer.Tabs[TabContainer.TabIndex - 1]
  else
    ChangeTabActionPrev.Tab := nil;

  CurTab := TabContainer.TabIndex;

end;

procedure TSellPage.FormCreate(Sender: TObject);
begin
//  FLayoutLandscape :=
  if Height > Width then
    begin
      l1.Align := TAlignLayout.Client;
      l2.Align := TAlignLayout.Bottom;
      l2.Height:=300;
    end
  else
    begin
      l1.Align := TAlignLayout.Client;
      l2.Align := TAlignLayout.Right;
      l2.Width:=300;
    end;
end;

procedure TSellPage.t1lResize(Sender: TObject);
begin
  {ShowMessage('rotated'); }
  if Height > Width then
    begin
      l1.Align := TAlignLayout.Client;
      l2.Align := TAlignLayout.Bottom;
      l2.Height:=300;
    end
  else
    begin
      l1.Align := TAlignLayout.Client;
      l2.Align := TAlignLayout.Right;
      l2.Width:=300;
    end;
 end;

end.
